import type { MockMethod } from 'vite-plugin-mock';
import config from '../_config';

export default [
	// 登录
	{
		url: '/user/login',
		method: 'post',
		timeout: config.timeout,
		response: ({ body }) => {
			console.log(body);
			if (body.loginName === 'admin' && body.password === 'e6e061838856bf47e1de730719fb2609') {
				return {
					code: config.resultCode,
					message: 'success',
					results: {
						id: 1,
						loginName: 'admin',
						roleName: '系统管理员',
						token: '4ea6bbe7-0f9b-44ee-a327-3437b6d08d32',
						type_: 'system',
						userName: 'admin',
					},
				};
			}
			return {
				code: 1001,
				message: 'FAILED',
				results: null,
				logMessage: null,
			};
		},
	},
	// 登出
	{
		url: '/user/logout',
		method: 'get',
		timeout: config.timeout,
		response: ({ body }) => {
			return {
				code: 1,
				message: 'success',
				results: null,
			};
		},
	},
	// 获取用户权限
	{
		url: '/authorize/getUserAuthorize',
		method: 'post',
		timeout: config.timeout,
		response: ({ body }) => {
			return {
				code: config.resultCode,
				message: 'SUCCESS',
				logMessage: null,
				results: [
					{
						id: 1,
						authName: 'overView',
						description: '数据总览',
						authType: 1,
					},
					{
						id: 2,
						authName: 'monitor',
						description: '电站监控',
						authType: 1,
					},
					{
						id: 3,
						authName: 'topo',
						description: '组态图',
						authType: 1,
					},
					{
						id: 4,
						authName: 'warning',
						description: '告警管理',
						authType: 1,
					},
					{
						id: 5,
						authName: 'report',
						description: '报表统计',
						authType: 1,
					},
					{
						id: 6,
						authName: 'iv',
						description: 'IV扫描',
						authType: 1,
					},
					{
						id: 21,
						authName: 'account',
						description: '账户管理',
						authType: 2,
					},
					{
						id: 22,
						authName: 'role',
						description: '角色管理',
						authType: 2,
					},
					{
						id: 23,
						authName: 'device',
						description: '设备管理',
						authType: 2,
					},
				],
			};
		},
	},
] as MockMethod[];
